package com.firebird.app.kotlin.stock.base

import androidx.lifecycle.Lifecycle
import com.uber.autodispose.AutoDispose
import com.uber.autodispose.AutoDisposeConverter
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider


abstract class BaseMvpFragment<T : BasePresenter<*>?> : BaseFragment(), BaseView {
    private var mPresenter: T? = null
    override fun onDestroyView() {
        super.onDestroyView()
        if (mPresenter != null) {
            mPresenter?.detachView()
        }
    }

    override fun <T> bindAutoDispose(): AutoDisposeConverter<T>? {
        return AutoDispose.autoDisposable(AndroidLifecycleScopeProvider
                .from(this, Lifecycle.Event.ON_DESTROY))
    }
}